@include('admin.common.header')

<!--tab nav start-->
<section class="panel">
    <header class="panel-heading tab-bg-dark-navy-blue ">
        <ul class="nav nav-tabs">
            <li @if ($_active['_action'] == 'list')  class="active" @endif>
                <a href="/admin/news">新闻列表</a>
            </li>
            <li @if ($_active['_action'] == 'add')  class="active" @endif>
                <a href="/admin/news/add">添加新闻</a>
            </li>
        </ul>
    </header>
    <div class="panel-body">

        <div class="tab-content">
            <div class="row cmxform form-horizontal tasi-form">
                <div class="col-lg-6">
                    <section class="panel">

                        <div class="panel-body">
                            <div class="form-group ">
                                <label for="name" class="control-label col-lg-2">内容管理</label>
                                <div class="col-lg-10">
                                    <input type="hidden" name="id" value="{{$news->id}}"/>
                                    <div style="width:1000px;height: 350px;" id="editor" name="article"></div>
                                </div>
                            </div>
                        </div>

                    </section>
                </div>
                <div class="col-lg-6">

                </div>
            </div>
            <div class="col-lg-12 text-center">
                <button class="btn btn-danger form-submitaaa" >编辑</button>
            </div>
        </div>
    </div>

</section>
<!--tab nav start-->

<script>
    var ue = UE.getEditor('editor', {
        autoHeight: false,
    });
    ue.ready(function() {
        ue.setContent('{!!$news->article!!}');
        $('.form-submitaaa').bind('click', function () {
            var html = ue.getContent();
            var id =$("input[name='id']").val();
            $.ajax({
                type: 'post',
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                url: '/admin/news/update/addarticle',
                data: {article:html,id:id},
                dataType: 'json',
                success: function(){
                    layer.msg('编辑成功');
                }
            });
        });
    });
    /*require(['app/cost'] , function (activity) {
        cost.ajaxAddCost();
    });*/
</script>

@include('admin.common.footer')